The coordinates of the Legionnairess Disease outbreaks will be used to gather weather data from surrounding stations. The averages of the data will be taken and outputted into a graph containing data from the last 10 years before the outbreak.

library(devtools)
library(rnoaa)
library(countyweather)
library(dplyr)
library(plyr)
library(tidyr)
library(weathermetrics)
library(ggplot2)
library(lubridate)
library(knitr)

I created a data frame including the locations of each outbreak. I found the coordinates at http://maps.cga.harvard.edu/gpf/ and crossed checked them with Google coordinates. The other data in this set are year of outbreak and the year 10 years before the outbreak, onset date, and 14 days before the onset date.

id file_id latitude longitude year_min date_min year_max date_max onset before_onset
portugal portugal 38.96 -8.99 2004 2004-01-01 2014 2014-12-31 2004-10-14 2004-09-30
pittsburgh pittsburgh 40.43 -79.98 2002 2002-01-01 2012 2012-12-31 2012-08-26 2012-08-12
quebec quebec 46.85 -71.34 2002 2002-01-01 2012 2012-12-31 2012-07-18 2012-07-04
stoke-on-trent stoke_on_trent 53.02 -2.15 2002 2002-01-01 2012 2012-12-31 2012-07-02 2012-06-18
edinburgh edinburgh 55.94 -3.20 2002 2002-01-01 2012 2012-12-31 2012-05-01 2012-04-17
miyazaki miyazaki 31.89 131.34 1992 1992-01-01 2002 2002-12-31 2002-07-18 2002-07-04
pas-de-calais pas_de_calais 50.51 2.37 1993 1993-01-01 2003 2003-12-31 2003-11-28 2003-11-14
pamplona pamplona 42.81 -1.65 1996 1996-01-01 2006 2006-12-31 2006-06-01 2006-05-18
rapid city rapid_city 44.06 -103.22 1995 1995-01-01 2005 2005-12-31 2005-05-26 2005-05-12
sarpsborg sarpsborg 59.28 11.08 1995 1995-01-01 2005 2005-12-31 2005-05-12 2005-04-28
barrow-in-furness barrow_in_furness 54.10 -3.22 1992 1992-01-01 2002 2002-12-31 2002-07-30 2002-07-16
murcia murcia 37.98 -1.12 1991 1991-01-01 2001 2001-12-31 2001-06-26 2001-06-12
melbourne melbourne -37.86 145.07 1990 1990-01-01 2000 2000-12-31 2000-04-17 2000-04-03
bovenkarspel bovenkarspel 52.70 5.24 1989 1989-01-01 1999 1999-12-31 1999-02-25 1999-02-11
london london 51.52 -0.10 1979 1979-01-01 1989 1989-12-31 1989-01-01 1988-12-18
sydney sydney -33.85 150.93 2006 2006-01-01 2016 2016-12-31 2016-04-25 2016-04-11
genesee1 genesee1 43.09 -83.63 2004 2004-01-01 2014 2014-12-31 2014-06-06 2014-05-23
genesee2 genesee2 43.09 -83.63 2005 2005-01-01 2015 2015-12-31 2015-05-04 2015-04-20
columbus columbus 39.98 -82.99 2003 2003-01-01 2013 2013-12-31 2013-07-09 2013-06-25
bronx bronx 40.82 -73.92 2005 2005-01-01 2015 2015-12-31 2015-07-12 2015-06-28

The next function will download information from all of the stations. It only needs to be downloaded once per session. It will take a couple minutes to download.

I created a loop to get a list of the stations within 30 km of the location.

station_data <- ghcnd_stations()[[1]]
df <- list()
for(i in 1:length(outbreak_loc$id))
  {
    df[[i]] <- (meteo_nearby_stations(lat_lon_df = outbreak_loc[i,],
                                    station_data = station_data,
                                    var = c("PRCP","TAVG","TMAX","TMIN",
                                            "AWND","MDPR"),
                                    year_min = outbreak_loc[i, "year_min"],
                                    year_max = outbreak_loc[i, "year_max"],
                                    radius = 30)[[1]])
  }

names(df) <- outbreak_loc$id
stations <- df
saveRDS(stations, file = "stations.RData")
## $portugal
## [1] id        name      latitude  longitude distance 
## <0 rows> (or 0-length row.names)
## 
## $pittsburgh
##             id                          name latitude longitude  distance
## 1  US1PAAL0014          PA PITTSBURGH 1.6 SW  40.4226  -79.9974  1.687108
## 2  US1PAAL0017           PA WHITEHALL 1.0 SW  40.3475  -80.0022  9.364279
## 3  USW00014762 PA PITTSBURGH ALLEGHENY CO AP  40.3547  -79.9217  9.720301
## 4  US1PAAL0011        PA WEST MIFFLIN 1.3 SW  40.3466  -79.9283 10.255413
## 5  US1PAAL0031      PA SCOTT TOWNSHIP 1.3 NW  40.3978  -80.0967 10.508788
## 6  USC00360861            PA BRADDOCK LOCK 2  40.3917  -79.8594 11.063215
## 7  US1PAAL0009                 PA PATHFINDER  40.3416  -80.0485 11.414110
## 8  USC00362574      PA EMSWORTH L/D OHIO RVR  40.5019  -80.0833 11.844197
## 9  US1PAAL0016            PA GLENSHAW 1.3 NW  40.5488  -79.9800 13.209957
## 10 USC00365573                 PA MCKEESPORT  40.3392  -79.8603 14.308275
## 11 US1PAAL0008    PA UPPER ST. CLAIR 1.7 WNW  40.3412  -80.1026 14.329100
## 12 US1PAAL0020         PA ALLISON PARK 0.7 W  40.5610  -79.9708 14.587294
## 13 US1PAAL0023 PA SOUTH PARK TOWNSHIP 0.2 NW  40.2989  -79.9970 14.648635
## 14 US1PAAL0003         PA SOUTH FAYETTE 2 SE  40.3381  -80.1159 15.392161
## 15 US1PAAL0001         PA BRIDGEVILLE 1.4 SW  40.3417  -80.1229 15.584945
## 16 US1PAAL0004           PA PENN HILLS 1.5 E  40.4759  -79.7982 16.207171
## 17 USC00360022           PA ACMETONIA LOCK 3  40.5361  -79.8153 18.254228
## 18 US1PAAL0006           PA MCDONALD 2.5 ENE  40.3822  -80.1871 18.323293
## 19 US1PAWS0005            PA MCMURRAY 0.2 NE  40.2831  -80.0857 18.628831
## 20 USW00094823         PA PITTSBURGH INTL AP  40.4847  -80.2144 20.743637
## 21 US1PAAL0030          PA CARNOT-MOON 0.9 S  40.5061  -80.2119 21.364459
## 22 USC00366111           PA MURRYSVILLE 2 SW  40.4119  -79.7244 21.730660
## 23 US1PAWT0001        PA NORTH IRWIN 2.5 WSW  40.3243  -79.7556 22.348628
## 24 USC00365918              PA MOON TOWNSHIP  40.5319  -80.2172 23.040372
## 25 USC00363343      PA GLENWILLARD DASHIELDS  40.5514  -80.2167 24.143027
## 26 US1PAWT0010        PA MURRYSVILLE 1.5 WSW  40.4317  -79.6813 25.282776
## 27 US1PAAL0012        PA SOUTH HEIGHTS 1.5 S  40.5533  -80.2379 25.760534
## 
## $quebec
##            id                         name latitude longitude  distance
## 1 CA007011309  QC CHARLESBOURG PARC ORLEAN  46.8667  -71.2667  5.874619
## 2 CA007016294 QC QUEBEC/JEAN LESAGE INTL A  46.8000  -71.3833  6.462488
## 3 CA00701S001   QC QUEBEC/JEAN LESAGE INTL  46.8000  -71.3833  6.462488
## 4 CA00701Q004        QC STE-FOY (U. LAVAL)  46.7833  -71.2833  8.580380
## 5 CA007010565                  QC BEAUPORT  46.8333  -71.2000 10.808994
## 6 CA007018572                QC VALCARTIER  46.9000  -71.5000 13.372471
## 7 CA007024254                    QC LAUZON  46.8167  -71.1000 18.628731
## 8 CA007020567                QC BEAUSEJOUR  46.6667  -71.1667 24.283856
## 9 CA007041330            QC CHATEAU RICHER  46.9667  -71.0333 26.668362
## 
## $`stoke-on-trent`
## [1] id        name      latitude  longitude distance 
## <0 rows> (or 0-length row.names)
## 
## $edinburgh
## [1] id        name      latitude  longitude distance 
## <0 rows> (or 0-length row.names)
## 
## $miyazaki
##            id       name latitude longitude  distance
## 1 JA000047830   MIYAZAKI   31.933   131.417  8.699733
## 2 JA000047829 MIYAKONOJO   31.733   131.083 29.908209
## 
## $`pas-de-calais`
## [1] id        name      latitude  longitude distance 
## <0 rows> (or 0-length row.names)
## 
## $pamplona
##            id                    name latitude longitude distance
## 1 SPE00120350 PAMPLONA (OBSERVATORIO)  42.8175   -1.6364 1.387848
## 2 SPE00120359                PAMPLONA  42.7767   -1.6500 3.702791
## 
## $`rapid city`
##             id                         name latitude longitude  distance
## 1  USC00396948            SD RAPID CITY WFO  44.0728 -103.2108  1.601898
## 2  USC00396947            SD RAPID CITY 4NW  44.1150 -103.2828  7.909484
## 3  USW00024090        SD RAPID CITY RGNL AP  44.0433 -103.0536 13.427258
## 4  USC00394343            SD JOHNSON SIDING  44.0839 -103.4342 17.317536
## 5  USR0000SBAK   SD BAKER PARK SOUTH DAKOTA  43.9792 -103.4250 18.692682
## 6  USC00396427               SD PACTOLA DAM  44.0622 -103.4819 20.928415
## 7  USC00394556                  SD KEYSTONE  43.9039 -103.4100 23.073539
## 8  USR0000SNEM         SD NEMO SOUTH DAKOTA  44.1917 -103.5097 27.370234
## 9  USC00395870      SD MT RUSHMORE NATL MEM  43.8769 -103.4578 27.869317
## 10 USR0000SMRU SD MT. RUSHMORE SOUTH DAKOTA  43.8750 -103.4583 28.051427
## 11 USC00393775             SD HERMOSA 3 SSW  43.8069 -103.2131 28.148859
## 
## $sarpsborg
##            id              name latitude longitude  distance
## 1 NOE00109849         SARPSBORG  59.2856   11.1144  2.050694
## 2 NOE00134298            FLOTER  59.4964   11.0131 24.358920
## 3 NOE00100575            HALDEN  59.1225   11.3883 24.795447
## 4 NOE00109786            HVALER  59.0358   11.0517 27.201683
## 5 NOE00109876 MOSS BRANNSTASJON  59.4428   10.6842 28.822789
## 6 NOE00109867              MOSS  59.4339   10.6667 29.008867
## 
## $`barrow-in-furness`
## [1] id        name      latitude  longitude distance 
## <0 rows> (or 0-length row.names)
## 
## $murcia
##            id                name latitude longitude distance
## 1 SPE00120323              MURCIA  38.0028   -1.1692 5.001690
## 2 SPE00120332 MURCIA/ALCANTARILLA  37.9578   -1.2294 9.902609
## 
## $melbourne
##             id                           name latitude longitude  distance
## 1  ASN00086018         CAULFIELD (RACECOURSE) -37.8795  145.0368  3.632396
## 2  ASN00086304      HAWTHORN (SCOTCH COLLEGE) -37.8361  145.0294  4.446429
## 3  ASN00086095           PRAHRAN (COMO HOUSE) -37.8376  145.0048  6.243145
## 4  ASN00086088 OAKLEIGH (METROPOLITAN GOLF CL -37.9142  145.0935  6.369850
## 5  ASN00086012     BOX HILL AGED MENS RETREAT -37.8364  145.1364  6.393542
## 6  ASN00086006                      BENTLEIGH -37.9279  145.0749  7.562369
## 7  ASN00086033 BRIGHTON (DENDY PARK BOWLING C -37.9252  145.0254  8.238821
## 8  ASN00086232    MELBOURNE BOTANICAL GARDENS -37.8303  144.9767  8.833034
## 9  ASN00086279                      NORTHCOTE -37.7797  145.0314  9.551015
## 10 ASN00086316     VERMONT TRANSPORT RESEARCH -37.8587  145.1847 10.070617
## 11 ASN00086071      MELBOURNE REGIONAL OFFICE -37.8075  144.9700 10.545355
## 12 ASN00086020     CHELTENHAM KINGSTON CENTRE -37.9551  145.0782 10.599081
## 13 ASN00086303    GLEN WAVERLEY (GOLF COURSE) -37.8886  145.1928 11.237859
## 14 ASN00086074                        MITCHAM -37.8219  145.1906 11.406147
## 15 ASN00086260                HEIDELBERG MMBW -37.7567  145.0533 11.579751
## 16 ASN00086378                      BRUNSWICK -37.7667  144.9797 13.059611
## 17 ASN00086111          SPRINGVALE NECROPOLIS -37.9445  145.1764 13.245203
## 18 ASN00086369           SPRINGVALE (SANDOWN) -37.9535  145.1655 13.352636
## 19 ASN00086068             VIEWBANK (ARPANSA) -37.7408  145.0972 13.468157
## 20 ASN00086077              MOORABBIN AIRPORT -37.9800  145.0964 13.542852
## 21 ASN00086146                      BEAUMARIS -37.9771  145.0273 13.548961
## 22 ASN00086362   DONCASTER (MANNINGHAM DEPOT) -37.7494  145.1703 15.129262
## 23 ASN00086351  BUNDOORA (LATROBE UNIVERSITY) -37.7163  145.0453 16.125457
## 24 ASN00086039          FLEMINGTON RACECOURSE -37.7915  144.9067 16.239778
## 25 ASN00086104    SCORESBY RESEARCH INSTITUTE -37.8710  145.2561 16.382188
## 26 ASN00086096              PRESTON RESERVOIR -37.7214  145.0059 16.408663
## 27 ASN00086230                      BAYSWATER -37.8372  145.2558 16.509685
## 28 ASN00086379                 RINGWOOD NORTH -37.7917  145.2433 17.010511
## 29 ASN00086101                       RINGWOOD -37.8000  145.2500 17.158761
## 30 ASN00086313                     WARRANDYTE -37.7469  145.2098 17.578887
## 31 ASN00086347       YARRA RIVER @ WARRANDYTE -37.7417  145.2167 18.416453
## 32 ASN00086224                      DANDENONG -37.9785  145.2235 18.839479
## 33 ASN00086035                         ELTHAM -37.7011  145.1547 19.172878
## 34 ASN00087038 MARIBYRNONG EXPLOSIVES FACTORY -37.7750  144.8767 19.432886
## 35 ASN00086324       FERNTREE GULLY (PROBERT) -37.8797  145.2964 19.993316
## 36 ASN00086027        CROYDON (SAMUEL STREET) -37.7903  145.2812 20.103933
## 37 ASN00086234        CROYDON (COUNCIL DEPOT) -37.7869  145.2847 20.535018
## 38 ASN00086038               ESSENDON AIRPORT -37.7276  144.9066 20.564229
## 39 ASN00087131          ALTONA (CITY OFFICES) -37.8633  144.8261 21.414594
## 40 ASN00087148    SUNSHINE (CITY OF BRINBANK) -37.7928  144.8344 22.000521
## 41 ASN00086250                         PLENTY -37.6600  145.1244 22.747356
## 42 ASN00086256                    FERNY CREEK -37.8833  145.3333 23.256162
## 43 ASN00086210              BONBEACH (CARRUM) -38.0651  145.1294 23.393049
## 44 ASN00086372       FERNY CREEK (DUNNS HILL) -37.8775  145.3364 23.465245
## 45 ASN00086365                    MOOROOLBARK -37.7792  145.3197 23.701976
## 46 ASN00086251            UPWEY SHIRE COUNCIL -37.9144  145.3317 23.749365
## 47 ASN00086243           MOUNT DANDENONG GTV9 -37.8306  145.3500 24.802430
## 48 ASN00086059                KANGAROO GROUND -37.6830  145.2518 25.351527
## 49 ASN00086254       CARRUM DOWNS SEWER WORKS -38.0783  145.1733 25.907856
## 50 ASN00086036                         EPPING -37.6312  144.9846 26.526359
## 51 ASN00086066                       LILYDALE -37.7488  145.3416 26.875070
## 52 ASN00086076                       MONTROSE -37.8019  145.3675 26.914609
## 53 ASN00086085 NARRE WARREN NORTH (NARRE WARR -37.9897  145.3356 27.399212
## 54 ASN00087031                  LAVERTON RAAF -37.8565  144.7566 27.516720
## 55 ASN00087027               KEILOR (ARUNDEL) -37.6942  144.8342 27.737658
## 56 ASN00087177            LAVERTON COMPARISON -37.8633  144.7456 28.480727
## 57 ASN00086305            GREENVALE RESERVOIR -37.6369  144.9072 28.640881
## 58 ASN00086384   MELBOURNE AIRPORT COMPARISON -37.6750  144.8419 28.725743
## 59 ASN00087015                         KEILOR -37.7025  144.8072 28.984935
## 
## $bovenkarspel
##             id          name latitude longitude  distance
## 1  NLE00101917     ENKHUIZEN  52.6917    5.2944  3.780363
## 2  NLE00109144   HOOGKARSPEL  52.6867    5.1669  5.143626
## 3  NLE00101928     MEDEMBLIK  52.7781    5.1014 12.746887
## 4  NLE00100501         HOORN  52.6444    5.0681 13.136277
## 5  NLE00102479      BERKHOUT  52.6428    4.9789 18.718869
## 6  NLE00109146      HOOGWOUD  52.7281    4.9608 19.065006
## 7  NLE00109174   KREILEROORD  52.8619    5.0953 20.464698
## 8  NLE00102134      STAVOREN  52.8967    5.3831 23.894441
## 9  NLE00109232         OBDAM  52.6775    4.8769 24.600539
## 10 NLE00109054          EDAM  52.5114    5.0467 24.701897
## 11 NLE00109250    OUDEMIRDUM  52.8608    5.5078 25.379621
## 12 NLE00109162       KOLHORN  52.7914    4.8919 25.540549
## 13 NLE00109354 WEST BEEMSTER  52.5817    4.9028 26.281190
## 14 NLE00101948     TOLLEBEEK  52.6719    5.6300 26.472774
## 15 NLE00101930     DEN OEVER  52.9217    5.0383 28.133541
## 16 NLE00101932        MARKEN  52.4600    5.1078 28.142012
## 17 NLE00109028     DE HAUKES  52.8783    4.9408 28.246661
## 18 NLE00109254     PURMEREND  52.5125    4.9506 28.575998
## 
## $london
##            id     name latitude longitude distance
## 1 UKM00003772 HEATHROW   51.478    -0.461 25.42177
## 
## $sydney
##             id                           name latitude longitude  distance
## 1  ASN00067019             PROSPECT RESERVOIR -33.8193  150.9127  3.769152
## 2  ASN00067017   GREYSTANES (BATHURST STREET) -33.8136  150.9392  4.135739
## 3  ASN00067070   MERRYLANDS (WELSFORD STREET) -33.8269  150.9767  5.020100
## 4  ASN00067114 ABBOTSBURY (FAIRFIELD CITY FAR -33.8667  150.8611  6.627566
## 5  ASN00067119 HORSLEY PARK EQUESTRIAN CENTRE -33.8511  150.8567  6.770114
## 6  ASN00067110  SEVEN HILLS  (RADIO FM 103.2) -33.7858  150.9236  7.163157
## 7  ASN00067026       SEVEN HILLS (COLLINS ST) -33.7704  150.9318  8.852678
## 8  ASN00067020 LIVERPOOL (MICHAEL WENDEN CENT -33.9214  150.8861  8.913714
## 9  ASN00066137          BANKSTOWN AIRPORT AWS -33.9181  150.9864  9.189477
## 10 ASN00066134       GRANVILLE SHELL REFINERY -33.8322  151.0340  9.806921
## 11 ASN00066168 MILPERRA BRIDGE (GEORGES RIVER -33.9289  150.9831 10.049571
## 12 ASN00067042    KINGS LANGLEY (SOLANDER RD) -33.7610  150.9498 10.064021
## 13 ASN00067111 NORTH PARRAMATTA (BURNSIDE HOM -33.7931  151.0167 10.206744
## 14 ASN00067109   BAULKHAM HILLS EUCALYPTUS CT -33.7678  150.9814 10.300292
## 15 ASN00066124 PARRAMATTA NORTH (MASONS DRIVE -33.7917  151.0181 10.404864
## 16 ASN00066050           POTTS HILL RESERVOIR -33.8933  151.0346 10.790772
## 17 ASN00066164       ROOKWOOD (HAWTHORNE AVE) -33.8771  151.0577 12.169844
## 18 ASN00067112 NORTH ROCKS (MUIRFIELD GOLF CL -33.7672  151.0186 12.319787
## 19 ASN00066195 SYDNEY OLYMPIC PARK (SYDNEY OL -33.8521  151.0646 12.431978
## 20 ASN00066070          STRATHFIELD GOLF CLUB -33.8805  151.0631 12.748603
## 21 ASN00066054         REVESBY (PATEN STREET) -33.9474  151.0065 12.928587
## 22 ASN00067076   QUAKERS HILL TREATMENT WORKS -33.7366  150.8758 13.567795
## 23 ASN00066185      CARLINGFORD (BARELLAN AV) -33.7801  151.0587 14.205035
## 24 ASN00066191        GLENFIELD (HARROW ROAD) -33.9770  150.9042 14.321038
## 25 ASN00067117       HOLSWORTHY CONTROL RANGE -33.9795  150.9254 14.405998
## 26 ASN00067102          ST CLAIR (JUBA CLOSE) -33.8044  150.7778 14.945410
## 27 ASN00067100     CASTLE HILL (KATHLEEN AVE) -33.7260  150.9944 15.017779
## 28 ASN00067089 WEST PENNANT HILLS (CUMBERLAND -33.7459  151.0402 15.416884
## 29 ASN00067003         COLYTON (CARPENTER ST) -33.7770  150.7877 15.450666
## 30 ASN00067098 WEST PENNANT HILLS  (ORATAVA A -33.7487  151.0449 15.478987
## 31 ASN00066013              CONCORD GOLF CLUB -33.8523  151.0985 15.562401
## 32 ASN00067061         ROSSMORE (SOUTH CREEK) -33.9353  150.7819 16.638119
## 33 ASN00066048             CONCORD (BRAYS RD) -33.8483  151.1105 16.669913
## 34 ASN00067037         SCHOFIELDS BOUNDARY RD -33.6947  150.8868 17.724215
## 35 ASN00066194      CANTERBURY RACECOURSE AWS -33.9057  151.1134 18.028240
## 36 ASN00066148            PEAKHURST GOLF CLUB -33.9700  151.0638 18.179759
## 37 ASN00066034 ABBOTSFORD (BLACKWALL POINT RD -33.8507  151.1295 18.423361
## 38 ASN00067116       WILLMOT (RESOLUTION AVE) -33.7231  150.7997 18.550317
## 39 ASN00066156 MACQUARIE PARK (WILLANDRA VILL -33.7791  151.1121 18.579019
## 40 ASN00066047   PENNANT HILLS (YARRARA ROAD) -33.7324  151.0767 18.835558
## 41 ASN00066190   INGLEBURN (SACKVILLE STREET) -34.0117  150.8647 18.962689
## 42 ASN00067108             BADGERYS CREEK AWS -33.8969  150.7281 19.355573
## 43 ASN00066181       OATLEY (WORONORA PARADE) -33.9766  151.0766 19.523783
## 44 ASN00066004            BEXLEY BOWLING CLUB -33.9430  151.1098 19.553323
## 45 ASN00067086      DURAL (OLD NORTHERN ROAD) -33.6867  151.0250 20.170027
## 46 ASN00066036         MARRICKVILLE GOLF CLUB -33.9186  151.1402 20.849104
## 47 ASN00066131          RIVERVIEW OBSERVATORY -33.8258  151.1556 21.009524
## 48 ASN00067104          BOX HILL (HYNDS ROAD) -33.6617  150.9000 21.120894
## 49 ASN00066189       WEST PYMBLE (WYUNA ROAD) -33.7693  151.1380 21.209116
## 50 ASN00067084  ORCHARD HILLS TREATMENT WORKS -33.8020  150.7069 21.288391
## 51 ASN00066204  OYSTER BAY (GREEN POINT ROAD) -34.0009  151.0738 21.391107
## 52 ASN00066158 TURRAMURRA (KISSING POINT ROAD -33.7366  151.1271 22.152621
## 53 ASN00066120               GORDON GOLF CLUB -33.7617  151.1462 22.258367
## 54 ASN00066078          LUCAS HEIGHTS (ANSTO) -34.0517  150.9800 22.897282
## 55 ASN00067015           BRINGELLY (MARYLAND) -33.9696  150.7250 23.124628
## 56 ASN00068160 CAMPBELLTOWN (KENTLYN (GEORGES -34.0542  150.8772 23.222412
## 57 ASN00068250      CAMDEN VALLEY GOLF RESORT -34.0128  150.7675 23.504569
## 58 ASN00066157      PYMBLE (CANISIUS COLLEGE) -33.7371  151.1521 24.058869
## 59 ASN00066058     SANS SOUCI (PUBLIC SCHOOL) -33.9942  151.1292 24.391064
## 60 ASN00067022      GALSTON (ROWLAND VILLAGE) -33.6550  151.0553 24.583503
## 61 ASN00068231          RUSE (DENISON STREET) -34.0630  150.8489 24.837610
## 62 ASN00066114   NORTH TURRAMURRA (DRYDEN RD) -33.7179  151.1470 24.858762
## 63 ASN00066037             SYDNEY AIRPORT AMO -33.9465  151.1731 24.870760
## 64 ASN00066062      SYDNEY (OBSERVATORY HILL) -33.8607  151.2050 25.421751
## 65 ASN00066011         CHATSWOOD BOWLING CLUB -33.8000  151.2000 25.553205
## 66 ASN00067115 GLENMORE PARK  (CARTWRIGHT CL) -33.7826  150.6619 25.877100
## 67 ASN00066006         SYDNEY BOTANIC GARDENS -33.8662  151.2160 26.470162
## 68 ASN00066080   CASTLE COVE (ROSEBRIDGE AVE) -33.7809  151.2044 26.489163
## 69 ASN00066176  AUDLEY  (ROYAL NATIONAL PARK) -34.0658  151.0567 26.689966
## 70 ASN00067029           WALLACIA POST OFFICE -33.8637  150.6410 26.729649
## 71 ASN00066206      ST IVES (RICHMOND AVENUE) -33.7096  151.1730 27.351861
## 72 ASN00067113              PENRITH LAKES AWS -33.7195  150.6783 27.416523
## 73 ASN00068257     CAMPBELLTOWN (MOUNT ANNAN) -34.0615  150.7735 27.594122
## 74 ASN00066073            RANDWICK RACECOURSE -33.9105  151.2276 28.284461
## 75 ASN00068254     MOUNT ANNAN BOTANIC GARDEN -34.0673  150.7678 28.418732
## 76 ASN00066160                CENTENNIAL PARK -33.8959  151.2341 28.535385
## 77 ASN00067031           WINDSOR BOWLING CLUB -33.6100  150.8151 28.724326
## 78 ASN00066188         BELROSE (EVELYN PLACE) -33.7402  151.2173 29.221247
## 79 ASN00066052          RANDWICK BOWLING CLUB -33.9096  151.2419 29.545881
## 80 ASN00066086                   CRONULLA STP -34.0313  151.1642 29.549535
## 81 ASN00067010     GLENORIE (OLD NORTHERN RD) -33.5908  151.0094 29.742533
## 
## $genesee1
##             id                    name latitude longitude  distance
## 1  USC00201150            MI BURTON 4N  43.0675  -83.5919  3.979309
## 2  US1MIGN0010       MI BURTON 0.9 NNW  43.0085  -83.6274  9.064849
## 3  US1MIGN0008 MI MOUNT MORRIS 3.1 WSW  43.1057  -83.7580 10.538333
## 4  US1MIGN0014       MI DAVISON 3.3 SW  43.0003  -83.5684 11.159857
## 5  US1MIGN0005      MI DAVISON 0.7 SSW  43.0219  -83.5246 11.431375
## 6  USC00202851            MI FLINT 7 W  43.0378  -83.7694 12.725462
## 7  USC00201645                 MI CLIO  43.1794  -83.7369 13.193328
## 8  US1MIGN0009        MI BURTON 3.3 SW  42.9613  -83.6636 14.569099
## 9  USW00014826 MI FLINT BISHOP INTL AP  42.9667  -83.7494 16.797891
## 10 US1MIGN0023  MI GRAND BLANC 3.8 WNW  42.9440  -83.6886 16.919078
## 11 US1MISG0004    MI BIRCH RUN 2.6 ESE  43.2291  -83.7470 18.146491
## 12 US1MIGN0020 MI SWARTZ CREEK 2.0 NNE  42.9897  -83.8166 18.824526
## 13 US1MIGN0015        MI FLINT 6.4 SSW  42.9326  -83.7210 19.001794
## 14 US1MIGN0018   MI GRAND BLANC 0.7 SE  42.9187  -83.6079 19.132279
## 15 USC00203278             MI GOODRICH  42.9164  -83.5097 21.640755
## 16 USC00204659            MI LAPEER 2W  43.0581  -83.3606 22.167570
## 17 US1MIGN0022   MI GRAND BLANC 2.9 SE  42.8909  -83.5858 22.428899
## 18 US1MIGN0004      MI MONTROSE 0.4 NW  43.1794  -83.8987 23.962697
## 19 USC00205488      MI MILLINGTON 3 SE  43.2836  -83.4792 24.756898
## 20 US1MILP0003       MI LAPEER 1.1 SSW  43.0316  -83.3293 25.277892
## 21 USC00204655          MI LAPEER WWTP  43.0608  -83.3075 26.394851
## 22 USC00202955      MI FRANKENMUTH 1SE  43.3194  -83.7161 26.445482
## 
## $genesee2
##             id                    name latitude longitude  distance
## 1  USC00201150            MI BURTON 4N  43.0675  -83.5919  3.979309
## 2  US1MIGN0010       MI BURTON 0.9 NNW  43.0085  -83.6274  9.064849
## 3  US1MIGN0008 MI MOUNT MORRIS 3.1 WSW  43.1057  -83.7580 10.538333
## 4  US1MIGN0014       MI DAVISON 3.3 SW  43.0003  -83.5684 11.159857
## 5  US1MIGN0005      MI DAVISON 0.7 SSW  43.0219  -83.5246 11.431375
## 6  USC00202851            MI FLINT 7 W  43.0378  -83.7694 12.725462
## 7  US1MIGN0024          MI CLIO 0.4 SW  43.1725  -83.7423 12.930649
## 8  USC00201645                 MI CLIO  43.1794  -83.7369 13.193328
## 9  US1MIGN0009        MI BURTON 3.3 SW  42.9613  -83.6636 14.569099
## 10 USW00014826 MI FLINT BISHOP INTL AP  42.9667  -83.7494 16.797891
## 11 US1MIGN0023  MI GRAND BLANC 3.8 WNW  42.9440  -83.6886 16.919078
## 12 US1MISG0004    MI BIRCH RUN 2.6 ESE  43.2291  -83.7470 18.146491
## 13 US1MIGN0020 MI SWARTZ CREEK 2.0 NNE  42.9897  -83.8166 18.824526
## 14 US1MIGN0015        MI FLINT 6.4 SSW  42.9326  -83.7210 19.001794
## 15 US1MIGN0018   MI GRAND BLANC 0.7 SE  42.9187  -83.6079 19.132279
## 16 USC00203278             MI GOODRICH  42.9164  -83.5097 21.640755
## 17 USC00204659            MI LAPEER 2W  43.0581  -83.3606 22.167570
## 18 US1MIGN0022   MI GRAND BLANC 2.9 SE  42.8909  -83.5858 22.428899
## 19 US1MIGN0004      MI MONTROSE 0.4 NW  43.1794  -83.8987 23.962697
## 20 USC00205488      MI MILLINGTON 3 SE  43.2836  -83.4792 24.756898
## 21 US1MILP0003       MI LAPEER 1.1 SSW  43.0316  -83.3293 25.277892
## 22 USC00204655          MI LAPEER WWTP  43.0608  -83.3075 26.394851
## 23 USC00202955      MI FRANKENMUTH 1SE  43.3194  -83.7161 26.445482
## 
## $columbus
##             id                              name latitude longitude
## 1  US1OHFR0018               OH COLUMBUS 2.4 WNW  39.9977  -83.0323
## 2  US1OHFR0025               OH COLUMBUS 2.8 WSW  39.9804  -83.0397
## 3  US1OHFR0003        OH GRANDVIEW HEIGHTS 0.1 N  39.9810  -83.0401
## 4  USC00331785                  OH COLUMBUS WCMH  40.0250  -83.0269
## 5  US1OHFR0034                OH COLUMBUS 3.6 NW  40.0191  -83.0437
## 6  US1OHFR0020                OH COLUMBUS 3.5 NE  40.0287  -82.9477
## 7  US1OHFR0001          OH UPPER ARLINGTON 0.9 E  40.0279  -83.0543
## 8  US1OHFR0021           OH MARBLE CLIFF 1.1 WNW  39.9931  -83.0786
## 9  US1OHFR0007        OH UPPER ARLINGTON 1.3 SSW  40.0112  -83.0832
## 10 USW00014821 OH COLUMBUS PORT COLUMBUS INTL AP  39.9914  -82.8808
## 11 USC00331783       OH COLUMBUS-VALLEY CROSSING  39.9047  -82.9200
## 12 US1OHFR0012        OH UPPER ARLINGTON 2.4 NNW  40.0604  -83.0815
## 13 USC00331777        OH COLUMBUS-HAP CREMEAN WP  40.0603  -82.8942
## 14 US1OHFR0024               OH COLUMBUS 9.3 NNE  40.0925  -82.9582
## 15 USW00004804    OH COLUMBUS OHIO STATE UNIV AP  40.0781  -83.0781
## 16 US1OHFR0037             OH REYNOLDSBURG 1.6 W  39.9588  -82.8294
## 17 US1OHFR0016                 OH DUBLIN 3.7 ESE  40.0923  -83.0725
## 18 US1OHFR0022                 OH GALLOWAY 3.1 N  39.9561  -83.1592
## 19 USC00331779          OH COLUMBUS-PARSONS AVE.  39.8469  -82.9872
## 20 USC00338951                    OH WESTERVILLE  40.1264  -82.9433
## 21 US1OHFR0010            OH WESTERVILLE 0.2 WNW  40.1226  -82.9213
## 22 US1OHFR0030                 OH HILLIARD 1.8 W  40.0344  -83.1768
## 23 US1OHFR0008             OH NEW ALBANY 2.8 SSE  40.0403  -82.7980
## 24 US1OHFR0002                 OH DUBLIN 3.2 ENE  40.1299  -83.0742
## 25 US1OHLC0002              OH PATASKALA 4.4 WNW  40.0273  -82.7490
## 26 US1OHFF0005           OH PICKERINGTON 2.7 NNE  39.9263  -82.7469
## 27 US1OHDL0002              OH WESTERVILLE 4.0 N  40.1790  -82.9256
## 28 US1OHFR0023             OH HARRISBURG 3.7 WNW  39.8378  -83.2321
## 29 US1OHLC0011               OH PATASKALA 2.0 NE  40.0240  -82.6511
##     distance
## 1   4.106137
## 2   4.234920
## 3   4.270197
## 4   5.909011
## 5   6.310790
## 6   6.504242
## 7   7.639623
## 8   7.687720
## 9   8.664212
## 10  9.389591
## 11 10.282003
## 12 11.858973
## 13 12.094496
## 14 12.799033
## 15 13.238469
## 16 13.887609
## 17 14.326951
## 18 14.662096
## 19 14.801971
## 20 16.757176
## 21 16.900247
## 22 17.021110
## 23 17.673463
## 24 18.143413
## 25 21.190424
## 26 21.564691
## 27 22.796070
## 28 26.008132
## 29 29.278406
## 
## $bronx
##             id                        name latitude longitude  distance
## 1  USW00014732    NY NEW YORK LAGUARDIA AP  40.7794  -73.8803  5.616756
## 2  USW00094728    NY NEW YORK CNTRL PK TWR  40.7789  -73.9692  6.167420
## 3  USC00300961                    NY BRONX  40.8369  -73.8494  6.230297
## 4  US1NJBG0018   NJ PALISADES PARK 0.2 WNW  40.8481  -74.0002  7.435652
## 5  US1NJBG0003            NJ TENAFLY 1.3 W  40.9147  -73.9775 11.587163
## 6  US1NYQN0002    NY MIDDLE VILLAGE 0.5 SW  40.7145  -73.8819 12.161951
## 7  USW00094741             NJ TETERBORO AP  40.8500  -74.0614 12.354793
## 8  US1NJBG0001       NJ BERGENFIELD 0.3 SW  40.9213  -74.0020 13.206762
## 9  US1NJBG0012        NJ WOOD RIDGE 0.6 SE  40.8420  -74.0830 13.930427
## 10 US1NJBG0033       NJ WOOD RIDGE 0.6 NNW  40.8536  -74.0943 15.131881
## 11 US1NYWC0009       NY NEW ROCHELLE 1.3 S  40.9040  -73.7770 15.226895
## 12 US1NJBG0013         NJ RUTHERFORD 1.2 N  40.8373  -74.1065 15.809146
## 13 US1NYKN0025          NY BROOKLYN 3.1 NW  40.6846  -73.9867 16.069963
## 14 US1NJBG0031         NJ DEMAREST 0.6 NNW  40.9628  -73.9600 16.230719
## 15 US1NJBG0002   NJ SADDLE BROOK TWP 0.6 E  40.9027  -74.0834 16.534408
## 16 US1NJBG0011   NJ NORTH ARLINGTON 0.7 NE  40.7944  -74.1190 16.988985
## 17 US1NJBG0008 NJ SADDLE BROOK TWP 0.3 NNE  40.9071  -74.0934 17.505118
## 18 USC00286146              NJ NEW MILFORD  40.9611  -74.0158 17.635536
## 19 US1NJBG0015  NJ NORTH ARLINGTON 0.7 WNW  40.7915  -74.1398 18.769309
## 20 US1NJHD0002            NJ KEARNY 1.7 NW  40.7729  -74.1409 19.318492
## 21 US1NJBG0005         NJ WESTWOOD 0.8 ESE  40.9830  -74.0159 19.836072
## 22 US1NJBG0010     NJ RIVER VALE TWP 1.5 S  40.9915  -74.0123 20.587159
## 23 US1NYNS0007        NY FLORAL PARK 0.4 W  40.7230  -73.7110 20.642010
## 24 US1NJHD0001           NJ HARRISON 0.3 N  40.7480  -74.1518 21.094543
## 25 USC00283704                 NJ HARRISON  40.7514  -74.1567 21.338273
## 26 US1NJBG0020          NJ PARAMUS 1.8 NNW  40.9682  -74.0902 21.822558
## 27 USC00302129      NY DOBBS FERRY-ARDSLEY  41.0072  -73.8344 22.023427
## 28 US1NJBG0017        NJ GLEN ROCK 0.7 SSE  40.9511  -74.1183 22.145027
## 29 US1NJES0020         NJ BLOOMFIELD 1.7 S  40.7850  -74.1885 22.932509
## 30 US1NYKN0003          NY BROOKLYN 2.4 SW  40.6194  -73.9859 22.986706
## 31 US1NYWC0005         NY HARRISON 4.1 SSW  40.9639  -73.7232 23.014851
## 32 USC00307587                NY SEA CLIFF  40.8506  -73.6483 23.109762
## 33 US1NJBG0037        NJ GLEN ROCK 0.4 WNW  40.9614  -74.1328 23.815579
## 34 US1NJPS0014        NJ HAWTHORNE 1.0 SSE  40.9436  -74.1523 23.880745
## 35 USC00289832           NJ WOODCLIFF LAKE  41.0139  -74.0425 23.891667
## 36 US1NJES0015        NJ MONTCLAIR 2.2 NNE  40.8565  -74.2004 23.935385
## 37 USW00094789     NY NEW YORK JFK INTL AP  40.6386  -73.7622 24.159135
## 38 US1NJPS0017     NJ WOODLAND PARK 0.1 NW  40.8918  -74.1960 24.547061
## 39 US1NJPS0005          NJ HAWTHORNE 0.4 S  40.9519  -74.1577 24.787058
## 40 US1NJES0011   NJ CEDAR GROVE TWP 0.9 NE  40.8648  -74.2157 25.368252
## 41 USC00305796        NY NY AVE V BROOKLYN  40.5939  -73.9808 25.658206
## 42 US1NJPS0018           NJ PATERSON 2.0 W  40.9163  -74.2005 25.903423
## 43 USW00014734           NJ NEWARK INTL AP  40.6825  -74.1694 25.982975
## 44 US1NJPS0003 NJ LITTLE FALLS TWP 0.2 NNW  40.8788  -74.2205 26.107408
## 45 US1NJPS0012 NJ LITTLE FALLS TWP 0.5 WNW  40.8796  -74.2270 26.658883
## 46 USC00284887             NJ LITTLE FALLS  40.8858  -74.2261 26.764590
## 47 US1NJES0024    NJ CEDAR GROVE TWP 0.4 W  40.8557  -74.2356 26.845270
## 48 US1NYNS0014          NY LYNBROOK 0.3 NW  40.6623  -73.6780 26.891776
## 49 USC00285503             NJ MIDLAND PARK  40.9939  -74.1453 27.062890
## 50 USC00305377                  NY MINEOLA  40.7328  -73.6183 27.191818
## 51 US1NJPS0004      NJ NORTH HALEDON 0.6 N  40.9713  -74.1856 27.953822
## 52 US1NJES0010        NJ VERONA TWP 0.7 SW  40.8255  -74.2531 28.035405
## 53 US1NJES0021       NJ VERONA TWP 0.6 WSW  40.8305  -74.2539 28.119240
## 54 US1NJES0004   NJ NORTH CALDWELL 0.6 SSE  40.8576  -74.2523 28.265572
## 55 US1NJPS0008        NJ WAYNE TWP 1.1 ESE  40.9412  -74.2267 29.094312
## 56 US1NYWC0003     NY WHITE PLAINS 3.1 NNW  41.0639  -73.7722 29.826697
## 57 US1NYNS0009         NY MILL NECK 1.1 SW  40.8704  -73.5717 29.828998
## 58 US1NYRL0005       NY WEST NYACK 1.3 WSW  41.0835  -73.9930 29.934369

Not all the locations have stations nearby. Therefore, I will omit them from the weather data evaluation using the following code.

has_stations <- sapply(stations, function(x) nrow(x) > 0)
outbreak_loc_true <- outbreak_loc %>%  filter(has_stations)
outbreak_loc_true
##              id      file_id latitude longitude year_min   date_min
## 1    pittsburgh   pittsburgh    40.43    -79.98     2002 2002-01-01
## 2        quebec       quebec    46.85    -71.34     2002 2002-01-01
## 3      miyazaki     miyazaki    31.89    131.34     1992 1992-01-01
## 4      pamplona     pamplona    42.81     -1.65     1996 1996-01-01
## 5    rapid city   rapid_city    44.06   -103.22     1995 1995-01-01
## 6     sarpsborg    sarpsborg    59.28     11.08     1995 1995-01-01
## 7        murcia       murcia    37.98     -1.12     1991 1991-01-01
## 8     melbourne    melbourne   -37.86    145.07     1990 1990-01-01
## 9  bovenkarspel bovenkarspel    52.70      5.24     1989 1989-01-01
## 10       london       london    51.52     -0.10     1979 1979-01-01
## 11       sydney       sydney   -33.85    150.93     2006 2006-01-01
## 12     genesee1     genesee1    43.09    -83.63     2004 2004-01-01
## 13     genesee2     genesee2    43.09    -83.63     2005 2005-01-01
## 14     columbus     columbus    39.98    -82.99     2003 2003-01-01
## 15        bronx        bronx    40.82    -73.92     2005 2005-01-01
##    year_max   date_max      onset before_onset
## 1      2012 2012-12-31 2012-08-26   2012-08-12
## 2      2012 2012-12-31 2012-07-18   2012-07-04
## 3      2002 2002-12-31 2002-07-18   2002-07-04
## 4      2006 2006-12-31 2006-06-01   2006-05-18
## 5      2005 2005-12-31 2005-05-26   2005-05-12
## 6      2005 2005-12-31 2005-05-12   2005-04-28
## 7      2001 2001-12-31 2001-06-26   2001-06-12
## 8      2000 2000-12-31 2000-04-17   2000-04-03
## 9      1999 1999-12-31 1999-02-25   1999-02-11
## 10     1989 1989-12-31 1989-01-01   1988-12-18
## 11     2016 2016-12-31 2016-04-25   2016-04-11
## 12     2014 2014-12-31 2014-06-06   2014-05-23
## 13     2015 2015-12-31 2015-05-04   2015-04-20
## 14     2013 2013-12-31 2013-07-09   2013-06-25
## 15     2015 2015-12-31 2015-07-12   2015-06-28

Using the countyweather codes I can gather the data for each station in a loop. The code gathers the weather data for each stations and averages them. Then I saved all the data as rds. files because they take a long time to gather. The data is saved in a folder I created called “weather_files/”

for(i in which(has_stations))
{
  meteo_df <- meteo_pull_monitors(monitors = stations[[i]]$id,
                                  keep_flags = FALSE,
                                  date_min = outbreak_loc$date_min[i],
                                  date_max = outbreak_loc$date_max[i],
                                  var = c("prcp","snow","snwd","tmax","tmin","tavg"))

  coverage_df <- rnoaa::meteo_coverage(meteo_df, verbose = FALSE)
  filtered <- countyweather:::filter_coverage(coverage_df, 0.90)
  good_monitors <- unique(filtered$id)
  filtered_data <- dplyr::filter(meteo_df, id %in% good_monitors)
  averaged <- countyweather:::ave_daily(filtered_data)

  # For metrics that are reported in tenths of units (precipitation
  # and temperature), divide by 10 to get values in degrees Celsius and
  # millimeters
  which_tenth_units <- which(colnames(averaged) %in%
                               c("prcp", "tavg", "tmax", "tmin"))
  averaged[ , which_tenth_units] <- averaged[ , which_tenth_units] / 10

  file_name <- paste0("weather_files/", outbreak_loc$file_id[i], ".rds")
  saveRDS(averaged, file_name)
}

Now that all of the data is gathered and averaged I can plot the data. The loop will go through the files in order which is in alphabetical order. Therefore I must order my outbreak data frame into alphabetical order too. I will rename this data frame as df_stations for plotting.

##              id      file_id latitude longitude year_min   date_min
## 1  bovenkarspel bovenkarspel    52.70      5.24     1989 1989-01-01
## 2         bronx        bronx    40.82    -73.92     2005 2005-01-01
## 3      columbus     columbus    39.98    -82.99     2003 2003-01-01
## 4      genesee1     genesee1    43.09    -83.63     2004 2004-01-01
## 5      genesee2     genesee2    43.09    -83.63     2005 2005-01-01
## 6        london       london    51.52     -0.10     1979 1979-01-01
## 7     melbourne    melbourne   -37.86    145.07     1990 1990-01-01
## 8      miyazaki     miyazaki    31.89    131.34     1992 1992-01-01
## 9        murcia       murcia    37.98     -1.12     1991 1991-01-01
## 10     pamplona     pamplona    42.81     -1.65     1996 1996-01-01
## 11   pittsburgh   pittsburgh    40.43    -79.98     2002 2002-01-01
## 12       quebec       quebec    46.85    -71.34     2002 2002-01-01
## 13   rapid city   rapid_city    44.06   -103.22     1995 1995-01-01
## 14    sarpsborg    sarpsborg    59.28     11.08     1995 1995-01-01
## 15       sydney       sydney   -33.85    150.93     2006 2006-01-01
##    year_max   date_max      onset before_onset
## 1      1999 1999-12-31 1999-02-25   1999-02-11
## 2      2015 2015-12-31 2015-07-12   2015-06-28
## 3      2013 2013-12-31 2013-07-09   2013-06-25
## 4      2014 2014-12-31 2014-06-06   2014-05-23
## 5      2015 2015-12-31 2015-05-04   2015-04-20
## 6      1989 1989-12-31 1989-01-01   1988-12-18
## 7      2000 2000-12-31 2000-04-17   2000-04-03
## 8      2002 2002-12-31 2002-07-18   2002-07-04
## 9      2001 2001-12-31 2001-06-26   2001-06-12
## 10     2006 2006-12-31 2006-06-01   2006-05-18
## 11     2012 2012-12-31 2012-08-26   2012-08-12
## 12     2012 2012-12-31 2012-07-18   2012-07-04
## 13     2005 2005-12-31 2005-05-26   2005-05-12
## 14     2005 2005-12-31 2005-05-12   2005-04-28
## 15     2016 2016-12-31 2016-04-25   2016-04-11

PLOT 1

Outbreak Distribution

This plot is divided by outbreaks in the northern and southern hemisphere. This allows us to see when the outbreaks generally occur in the year.

PLOT 2

10 years for all data

These plots allow for a quick glance into all the weather variables for each location.

## Warning: Removed 5 rows containing missing values (geom_path).

## Warning: Removed 1 rows containing missing values (geom_path).

## Warning: Removed 27 rows containing missing values (geom_path).

PLOT 3

TMAX and TMIN

## Warning: Removed 1100 rows containing missing values (geom_path).

## Warning: Removed 5 rows containing missing values (geom_path).

## Warning: Removed 1 rows containing missing values (geom_path).

## Warning: Removed 55 rows containing missing values (geom_path).

PLOT 4

Precipitation

I also made a loop to plot graphs and histograms of the data with lines indicating each day before the start of the outbreak for a total of 14 days.A plot of the percentiles is also included. The precentile data is saved for a plot of percentiles as shown later.

PLOT 5

TMAX

PLOT 6

TMIN

## Warning: Removed 550 rows containing missing values (geom_path).

## Warning: Removed 550 rows containing non-finite values (stat_bin).

## Warning: Removed 5 rows containing missing values (geom_path).

## Warning: Removed 1587 rows containing non-finite values (stat_bin).
## Warning: Removed 9 rows containing missing values (geom_vline).

## Warning: Removed 9 rows containing missing values (position_stack).

## Warning: Removed 1 rows containing missing values (geom_path).

## Warning: Removed 1595 rows containing non-finite values (stat_bin).
## Warning: Removed 5 rows containing missing values (geom_vline).

## Warning: Removed 5 rows containing missing values (position_stack).

## Warning: Removed 975 rows containing non-finite values (stat_bin).

## Warning: Removed 27 rows containing missing values (geom_path).

## Warning: Removed 27 rows containing non-finite values (stat_bin).

PERCENTILES

Table and Plots

Now I gathered a 2-week seasonal subset data for each weather variable and plotted it in a single table. I saved the table data for each outbreak and plotted them in a facetted plot.s

days_before_onset TMAX_year TMAX_seasonal TMIN_year TMIN_seasonal PRCP_year PRCP_seasonal outbreak
0 15.690799 54.814815 20.478800 56.296296 71.24720 67.87879 1
1 13.700606 48.148148 15.806173 47.407407 45.55639 39.39394 1
2 14.681281 52.592593 18.257860 51.851852 64.65024 60.60606 1
3 11.479665 41.481482 13.614076 42.222222 87.85163 92.12121 1
4 20.334583 64.444444 25.007211 66.666667 87.12970 90.90909 1
5 15.690799 54.814815 23.622729 63.703704 48.66816 43.03030 1
6 26.593597 74.074074 24.257283 65.925926 59.79587 56.96970 1
7 18.402077 58.518518 18.257860 51.851852 79.33781 80.60606 1
8 9.662532 35.555556 9.085665 33.333333 58.72542 52.72727 1
9 16.094606 57.037037 11.681569 37.037037 72.54170 69.69697 1
10 12.027690 43.703704 13.614076 42.222222 81.22977 83.63636 1
11 6.864725 28.888889 3.345832 14.814815 68.90714 64.84848 1
12 3.663109 13.333333 2.278627 10.370370 29.82325 18.78788 1
13 6.201327 25.925926 5.018748 20.000000 25.44187 15.15152 1
14 7.095472 29.629630 5.797519 22.222222 32.36246 21.81818 1
0 93.104307 67.272727 90.589992 55.757576 37.78940 30.90909 2
1 90.540204 61.818182 87.229276 44.848485 37.78940 30.90909 2
2 84.266866 37.575758 92.805576 67.272727 85.66094 86.66667 2
3 77.346278 19.393939 88.150361 47.878788 88.82250 90.90909 2
4 93.552402 69.090909 99.004232 94.545455 67.68733 63.03030 2
5 92.108539 64.848485 97.684839 89.090909 52.67613 44.84848 2
6 83.619617 34.545454 90.589992 55.757576 37.78940 30.90909 2
7 80.383371 29.090909 85.262634 36.969697 63.05701 58.78788 2
8 72.417227 10.909091 86.706497 41.212121 43.01718 35.15152 2
9 80.084640 27.878788 78.790142 20.000000 46.22853 38.78788 2
10 77.918845 21.212121 85.362211 37.575758 46.65173 39.39394 2
11 84.092606 36.363636 88.399303 49.090909 93.90092 93.33333 2
12 78.317152 23.636364 80.657207 24.242424 46.22853 38.78788 2
13 70.176749 6.060606 74.583022 12.727273 59.69629 54.54545 2
14 65.098332 2.424242 72.840428 6.060606 97.13717 97.57576 2
0 93.504231 72.727273 98.307616 96.969697 92.78248 90.30303 3
1 77.277252 27.878788 87.605774 52.727273 97.56098 95.75758 3
2 78.720757 32.121212 89.447486 60.000000 84.29567 77.57576 3
3 82.901941 40.606061 97.137879 93.333333 80.71180 73.93939 3
4 70.408163 13.939394 91.762071 69.696970 97.06322 94.54545 3
5 71.577900 18.181818 97.735192 95.757576 71.67745 63.03030 3
6 84.693878 46.666667 94.673967 84.848485 39.72125 37.57576 3
7 79.193629 34.545454 92.956695 75.151515 56.09756 49.09091 3
8 76.655052 26.060606 88.899950 56.969697 85.36585 79.39394 3
9 72.025884 18.787879 78.795421 29.696970 95.52016 93.33333 3
10 74.813340 21.818182 79.417621 31.515152 91.18965 87.87879 3
11 83.026381 41.212121 88.402190 54.545454 69.91040 62.42424 3
12 87.730214 54.545454 91.762071 69.696970 89.12394 84.84848 3
13 91.513191 65.454545 91.762071 69.696970 94.99751 92.12121 3
14 97.859632 89.696970 96.689896 90.909091 66.72474 60.00000 3
0 72.573420 52.727273 61.796914 23.030303 36.90891 36.96970 4
1 61.896466 21.212121 65.505227 36.363636 50.14933 51.51515 4
2 73.693380 56.969697 78.546541 60.606061 49.42758 50.90909 4
3 89.646590 80.000000 96.042807 98.181818 73.49428 69.69697 4
4 92.160279 86.060606 88.128422 81.212121 57.41663 57.57576 4
5 86.286710 75.151515 74.763564 55.757576 36.90891 36.96970 4
6 86.112494 73.939394 75.012444 56.969697 36.90891 36.96970 4
7 72.000996 49.696970 67.073171 41.212121 36.90891 36.96970 4
8 65.878546 36.969697 63.787954 29.090909 81.01045 76.96970 4
9 84.146342 71.515152 82.030861 70.909091 87.38178 87.27273 4
10 90.019910 80.606061 86.137382 80.000000 84.64410 83.03030 4
11 86.485814 75.757576 74.539572 54.545454 36.90891 36.96970 4
12 76.704828 60.606061 65.281234 35.151515 36.90891 36.96970 4
13 62.792434 24.242424 61.697362 21.818182 36.90891 36.96970 4
14 64.211050 29.696970 62.667994 24.242424 36.90891 36.96970 4
0 80.358476 95.757576 77.346278 96.969697 68.75778 63.63636 5
1 72.641275 90.909091 61.463779 76.969697 36.71894 34.54545 5
2 67.064974 80.000000 54.742345 60.606061 36.71894 34.54545 5
3 52.128454 47.878788 49.639034 46.060606 52.47697 48.48485 5
4 57.181977 64.848485 52.725915 54.545454 73.83620 67.27273 5
5 54.543191 56.969697 43.241225 30.303030 55.56385 52.12121 5
6 42.618870 26.060606 34.229524 12.121212 36.71894 34.54545 5
7 44.983819 32.121212 41.224795 25.454545 43.63953 42.42424 5
8 42.768235 27.272727 31.715210 7.272727 36.71894 34.54545 5
9 42.544187 24.848485 31.167538 6.060606 36.71894 34.54545 5
10 28.055763 3.030303 21.483694 1.212121 36.71894 34.54545 5
11 24.794623 1.212121 31.814787 8.484849 56.48494 53.93939 5
12 32.636296 6.666667 46.502365 40.606061 53.24869 49.69697 5
13 51.058003 46.666667 52.003983 52.727273 77.22181 69.69697 5
14 58.675629 69.090909 57.729649 68.484848 87.30396 84.84848 5
0 NaN NaN NaN NaN 54.36198 54.46880 6
1 19.630872 18.765091 NaN NaN 54.36198 54.46880 6
2 NaN NaN NaN NaN NaN NaN 6
3 NaN NaN 43.150967 42.361405 54.36198 54.46880 6
4 NaN NaN NaN NaN 54.36198 54.46880 6
5 NaN NaN NaN NaN NaN NaN 6
6 NaN NaN 65.981078 65.213711 54.36198 54.46880 6
7 34.697987 33.425319 43.150967 42.361405 NaN NaN 6
8 42.248322 40.772680 NaN NaN NaN NaN 6
9 42.248322 40.772680 NaN NaN 54.36198 54.46880 6
10 34.697987 33.425319 64.253394 63.478629 54.36198 54.46880 6
11 34.697987 33.425319 44.055944 43.250106 54.36198 54.46880 6
12 NaN NaN NaN NaN 54.36198 54.46880 6
13 35.436242 34.046223 NaN NaN 64.90885 64.85666 6
14 NaN NaN 22.459893 21.836648 54.36198 54.46880 6
0 54.131409 46.060606 53.111001 44.848485 83.00149 80.60606 7
1 72.722748 67.878788 84.544550 87.272727 59.35789 63.03030 7
2 71.304131 66.666667 56.943753 48.484848 88.35241 86.66667 7
3 68.292683 65.454545 94.524639 95.757576 85.26630 83.03030 7
4 79.019413 78.787879 90.219014 92.727273 20.35839 18.18182 7
5 85.689398 89.696970 72.772524 72.121212 20.35839 18.18182 7
6 85.988054 90.303030 79.790941 81.818182 32.95172 37.57576 7
7 82.055749 81.818182 74.489796 74.545455 20.35839 18.18182 7
8 87.431558 92.121212 66.177203 63.030303 20.35839 18.18182 7
9 82.503733 82.424242 31.408661 13.939394 27.05326 24.24242 7
10 61.448482 58.181818 41.961175 28.484848 20.35839 18.18182 7
11 58.536585 52.727273 36.635142 22.424242 53.80786 59.39394 7
12 53.583873 44.848485 76.754604 77.575758 98.45694 98.18182 7
13 72.175212 67.272727 52.040816 43.636364 21.30413 18.78788 7
14 74.066700 70.303030 70.930811 69.696970 39.59681 44.24242 7
0 76.093071 16.149068 NaN NaN 73.02185 78.04878 8
1 86.934288 48.447205 82.872472 27.586207 38.80934 40.24390 8
2 92.815137 64.596273 NaN NaN 28.56066 29.26829 8
3 83.175658 34.161491 NaN NaN 66.54107 69.51220 8
4 88.391716 52.173913 97.111019 87.068966 33.83572 34.14634 8
5 90.948606 57.763975 98.060256 93.965517 29.84175 30.48780 8
6 87.241115 49.068323 85.266199 42.241379 14.09194 12.19512 8
7 87.496804 49.689441 83.945522 35.344828 30.06782 31.70732 8
8 97.519816 81.366460 NaN NaN 14.09194 12.19512 8
9 87.599080 50.310559 97.853900 91.379310 42.65260 45.12195 8
10 88.263871 51.552795 87.825010 51.724138 28.56066 29.26829 8
11 84.709793 41.614907 84.275691 38.793103 NaN NaN 8
12 83.584761 36.645963 91.209245 64.655172 89.14846 86.58537 8
13 77.371516 19.875776 NaN NaN 81.91409 81.70732 8
14 77.090258 18.633540 95.542716 81.896552 32.78071 32.92683 8
0 99.850672 100.000000 91.388751 95.757576 83.00149 89.69697 9
1 99.004480 98.181818 84.395222 84.242424 83.00149 89.69697 9
2 98.282728 95.757576 84.494773 85.454545 83.00149 89.69697 9
3 99.825784 99.393939 78.496765 68.484848 83.00149 89.69697 9
4 99.153808 98.787879 73.544052 50.909091 83.00149 89.69697 9
5 93.852663 90.909091 68.367347 30.303030 83.00149 89.69697 9
6 79.442509 60.606061 63.862618 13.939394 83.00149 89.69697 9
7 63.364858 16.969697 72.847188 47.878788 83.00149 89.69697 9
8 62.792434 15.151515 84.046789 83.030303 83.00149 89.69697 9
9 75.684420 49.090909 67.098059 26.060606 83.00149 89.69697 9
10 86.361374 79.393939 90.467894 95.151515 83.00149 89.69697 9
11 96.416127 92.727273 78.496765 68.484848 83.00149 89.69697 9
12 94.848183 92.121212 79.890493 73.333333 83.00149 89.69697 9
13 87.680438 81.818182 69.362867 33.939394 83.00149 89.69697 9
14 63.937282 17.575758 65.355898 18.787879 83.00149 89.69697 9
0 60.129418 30.303030 39.347934 8.484849 59.98009 70.30303 10
1 46.565455 13.333333 51.294176 25.454545 59.98009 70.30303 10
2 45.644599 11.515151 62.020906 51.515152 59.98009 70.30303 10
3 63.937282 36.363636 78.571429 85.454545 59.98009 70.30303 10
4 88.626182 86.666667 80.537581 87.272727 59.98009 70.30303 10
5 92.458935 93.939394 69.437531 67.272727 59.98009 70.30303 10
6 75.385764 58.787879 74.912892 79.393939 59.98009 70.30303 10
7 72.598308 51.515152 37.406670 6.666667 59.98009 70.30303 10
8 56.470881 24.848485 28.297660 1.212121 59.98009 70.30303 10
9 42.508711 6.060606 42.483823 11.515151 59.98009 70.30303 10
10 63.265306 35.151515 66.923843 62.424242 70.05973 77.57576 10
11 85.813838 81.212121 72.125435 75.151515 59.98009 70.30303 10
12 65.778994 40.000000 62.344450 52.727273 59.98009 70.30303 10
13 63.066202 34.545454 54.952713 30.303030 59.98009 70.30303 10
14 65.778994 40.000000 82.205077 89.696970 59.98009 70.30303 10
0 92.906919 83.636364 85.365854 53.333333 26.80438 35.75758 11
1 92.906919 83.636364 82.478845 44.848485 26.80438 35.75758 11
2 91.886511 78.181818 78.596317 32.121212 26.80438 35.75758 11
3 84.420109 50.909091 74.589348 18.787879 48.78049 53.33333 11
4 78.919861 30.909091 71.353907 11.515151 62.51867 62.42424 11
5 75.958188 24.242424 72.448980 15.151515 47.83474 52.72727 11
6 78.944749 31.515152 76.679940 24.848485 62.91687 63.03030 11
7 75.236436 23.636364 76.779492 26.060606 34.71877 43.63636 11
8 72.672972 16.969697 78.496765 31.515152 68.84022 69.09091 11
9 79.417621 33.333333 89.472374 67.272727 69.16376 71.51515 11
10 87.605774 61.818182 83.349925 47.272727 26.80438 35.75758 11
11 80.711797 36.969697 87.580886 63.030303 77.20259 80.00000 11
12 85.788950 55.757576 87.282230 61.818182 66.72474 66.06061 11
13 79.766053 33.939394 83.822797 49.090909 30.76157 40.60606 11
14 67.894475 9.696970 83.051269 46.060606 35.54007 44.84848 11
0 83.897461 32.121212 87.755102 38.787879 29.96516 30.30303 12
1 73.842708 10.909091 97.336984 84.242424 92.53360 89.69697 12
2 91.314087 60.606061 99.128920 93.333333 71.90144 68.48485 12
3 99.253360 96.363636 93.529119 66.666667 99.20358 99.39394 12
4 97.187656 84.848485 97.212544 83.636364 29.96516 30.30303 12
5 99.104032 95.151515 95.843703 77.575758 29.96516 30.30303 12
6 97.038327 83.636364 86.436038 34.545454 29.96516 30.30303 12
7 91.015431 58.787879 73.544052 2.424242 29.96516 30.30303 12
8 86.460926 41.212121 80.338477 16.969697 29.96516 30.30303 12
9 85.042310 38.181818 82.852165 23.636364 29.96516 30.30303 12
10 79.168741 19.393939 89.024390 43.636364 29.96516 30.30303 12
11 96.042807 80.000000 98.158288 87.878788 29.96516 30.30303 12
12 93.056247 67.878788 93.728223 67.878788 29.96516 30.30303 12
13 90.841215 56.969697 94.300647 70.909091 32.27974 30.90909 12
14 81.981085 27.878788 93.529119 66.666667 76.92882 72.72727 12
0 52.065704 30.909091 61.523146 43.030303 72.17521 56.96970 13
1 52.090592 31.515152 63.339970 49.090909 97.73519 95.15152 13
2 64.410154 61.212121 71.378795 77.575758 90.89099 83.63636 13
3 73.668492 86.060606 76.356396 90.909091 51.94126 33.33333 13
4 76.331508 92.121212 70.109507 75.757576 51.94126 33.33333 13
5 79.965157 95.151515 81.159781 96.969697 51.94126 33.33333 13
6 86.162270 98.181818 82.105525 97.575758 51.94126 33.33333 13
7 84.619214 97.575758 73.444500 86.060606 51.94126 33.33333 13
8 70.681931 79.393939 73.295172 85.454545 57.41663 37.57576 13
9 70.532603 77.575758 72.672972 84.242424 71.92633 55.75758 13
10 75.136884 88.484848 72.025884 80.606061 51.94126 33.33333 13
11 66.898955 68.484848 45.943255 8.484849 51.94126 33.33333 13
12 45.196615 20.000000 44.997511 7.272727 51.94126 33.33333 13
13 39.696366 9.696970 42.259831 5.454546 72.17521 56.96970 13
14 26.903932 1.818182 38.352414 3.030303 99.45246 97.57576 13
0 73.184358 72.500000 40.354913 14.166667 31.85665 41.21212 14
1 64.344397 65.833333 46.171541 25.833333 41.09009 45.45455 14
2 50.607953 31.666667 46.565889 27.500000 67.02339 66.66667 14
3 50.607953 31.666667 44.134078 21.666667 72.32454 73.93939 14
4 49.030562 26.666667 44.134078 21.666667 74.51468 75.75758 14
5 52.152481 37.500000 48.209004 35.833333 24.71379 36.36364 14
6 58.724942 52.500000 46.335853 26.666667 24.71379 36.36364 14
7 52.152481 37.500000 34.538285 6.666667 49.22847 50.30303 14
8 52.875452 38.333333 65.856063 87.500000 24.71379 36.36364 14
9 58.724942 52.500000 63.851462 83.333333 64.03683 64.24242 14
10 50.607953 31.666667 59.710812 75.000000 76.18218 78.78788 14
11 62.668419 60.000000 59.710812 75.000000 77.25236 80.60606 14
12 47.321722 20.833333 60.893855 76.666667 61.07516 60.00000 14
13 57.837660 50.000000 52.875452 50.833333 85.26630 89.69697 14
14 64.344397 65.833333 42.885311 18.333333 24.71379 36.36364 14
0 52.791109 53.333333 41.414141 21.818182 46.59091 38.18182 15
1 46.956302 40.000000 59.772727 72.727273 87.65152 81.21212 15
2 32.306138 17.575758 63.358586 81.212121 81.11111 73.93939 15
3 69.133620 85.454545 59.545454 71.515152 57.67677 46.06061 15
4 77.721647 92.121212 62.095960 77.575758 26.86869 18.78788 15
5 70.093458 86.666667 59.848485 73.333333 71.36364 62.42424 15
6 58.651175 65.454545 65.984848 85.454545 89.19192 83.03030 15
7 54.079313 55.151515 56.363636 61.818182 80.05051 71.51515 15
8 50.543066 48.484848 80.429293 96.969697 64.77273 53.33333 15
9 81.156858 94.545455 55.075758 55.757576 49.26768 40.60606 15
10 76.483961 90.303030 58.813131 69.696970 64.52020 52.72727 15
11 53.447840 53.939394 54.898990 55.151515 66.99495 54.54545 15
12 57.438747 62.424242 56.565657 62.424242 66.43939 53.93939 15
13 49.078050 44.848485 74.015152 94.545455 79.06566 70.30303 15
14 70.346047 87.272727 43.787879 27.272727 20.83333 14.54545 15
## Warning: Removed 8 rows containing missing values (position_stack).

## Warning: Removed 8 rows containing missing values (position_stack).

## Warning: Removed 14 rows containing missing values (position_stack).

## Warning: Removed 14 rows containing missing values (position_stack).

## Warning: Removed 5 rows containing missing values (position_stack).

## Warning: Removed 5 rows containing missing values (position_stack).